package my.org.swing.date;

import java.time.LocalDate;

public class CellValue {

    private final int year;

    private final int month;

    private final int day;

    private int mode = 2;

    public CellValue(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public CellValue(LocalDate date) {
        this.year = date.getYear();
        this.month = date.getMonthValue();
        this.day = date.getDayOfMonth();
    }

    public int getYear() {
        return year;
    }

    public int getMonth() {
        return month;
    }

    public int getDay() {
        return day;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public LocalDate toLocalDate() {
        return LocalDate.of(year, month, day);
    }

    @Override
    public String toString() {
        if (mode == 2) {
            return String.valueOf(day);
        }

        if (mode == 1) {
            return month + "月";
        }

        return year + "";
    }
}
